package edu.pku.sei.modeler.uml.commands.activity;

import edu.pku.sei.modeler.model.core.MetaModelElement;
import edu.pku.sei.modeler.model.uml.FundamentalActivities.ActivityNode;
import edu.pku.sei.modeler.uml.commands.ConnectionModelDeleteCommand;

public class DeleteActivityEdgeFlowCommand extends ConnectionModelDeleteCommand {
	
	private ActivityNode src, dst;
	public DeleteActivityEdgeFlowCommand(MetaModelElement connectionModel,
			MetaModelElement sourceModel, MetaModelElement targetModel) {
		super(connectionModel, sourceModel, targetModel);
		src = (ActivityNode) sourceModel;
		dst = (ActivityNode) targetModel;
	}
	
	public boolean canExecute() {
		return true;
	}
	
	@Override
	public void execute() {
		src.getOutgoing().remove(connectionModel);
		dst.getIncoming().remove(connectionModel);
		connectionModel.setContainer(null);
	}
	
	@Override
	public void undo() {
		src.getOutgoing().add(connectionModel);
		dst.getIncoming().add(connectionModel);
		connectionModel.setContainer(src);
	}

}
